﻿@model IEnumerable<PescarShop_1.Models.Producto>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdministrador.cshtml";

}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class ="table table-bordered" style="background-color:rgba(255, 255, 255, 0.85)">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Marca)
        </th>
        <th>
           @Html.DisplayNameFor(model => model.Nombre)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Modelo)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Precio)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Descripcion)
        </th>
        <th>
            imagen
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                <a href="~/Marcas/Details/@item.Marca.MarcaID">
                    @Html.DisplayFor(modelItem => item.Marca.Nombre)
                    <img src="@Html.DisplayFor(modelItem => item.Marca.Url)" height="100" width="100" />
                </a>           
             </td>
            <td>
                <a href="~/Home/Productos/@item.ID" target="_blank">
                    @Html.DisplayFor(modelItem => item.Nombre)
                    </a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Modelo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Precio)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Descripcion)
            </td>
            <td>
                @if (item.Url != null)
                { 
                    <img src="@Html.DisplayFor(modelItem => item.Url)" height="150" width="150"/> 
                }
                else
                { 
                    <img src="@Url.Content("~/Content/Productos/" + item.ID + ".jpg")" height="150" width="150"/> 
}
            </td> 

            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                <form action="~/Productos/Delete" method="get" name="id">
                    <input type="hidden" value="@item.ID" name="id" />
                    <input type="submit" value="Eliminar" />
                </form>     
            </td>
        </tr>
    }

</table>
